package com.hylanda.va.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.hylanda.va.entity.SysOrders;

/** 
 * @author zhangy
 * @E-mail:blackoon88@gmail.com 
 * @qq:846579287
 * @version created at：2018年5月15日 下午4:12:37 
 * note
 */
@Repository
public interface OrderRepository extends JpaRepository<SysOrders, Integer>,JpaSpecificationExecutor<SysOrders>{
	@Query("select w from SysOrders w where w.studio = :studio")
    List<SysOrders> searchStudio(@Param("studio") String studio);
	
//	@Modifying
//	@Transactional(readOnly = false)
//	@Query("update Order w set w.weiboText = :text where w.user = :user")
//	int setUserWeiboContent(@Param("text")String weiboText,@Param("user")Order user);
//	
	@Query(value="select studio name,sum(cost) value from sys_orders group by studio",nativeQuery = true)
	Object[][] studioCostRank();
	
	@Query(value="select studio name,count(order_id) value from sys_orders group by studio",nativeQuery = true)
	Object[][] studioOrderTotalRank();
}
